package com.ccc.scala.base1

import java.io.{BufferedReader, InputStreamReader}
import java.net.ServerSocket

object Base5_Network {
  // 网络
  def main(args: Array[String]): Unit = {
    val server = new ServerSocket(9999);
    while (true) {
      val socket = server.accept()
      val reader = new BufferedReader(
        new InputStreamReader(
          socket.getInputStream,
          "UTF-8"
        )
      )
      var s: String = ""
      var flg = true
      while (flg) {
        s = reader.readLine()
        if (s != null) println(s)
        else flg = false
      }
    }
  }
}
